@echo off
echo "==>TAO_ROOT=%TAO_ROOT%"

set PROJECT_PATH="%TAO_ROOT%/orbsvcs/tests/FT_App"

cd %PROJECT_PATH%


@echo off
setlocal

:: 定义要删除的文件列表
set "files=*.ior"

:: 删除文件
for %%f in (%files%) do (
    if exist "%%f" (
        echo Deleting %%f...
        del "%%f"
        if not errorlevel 1 (
            echo Deleted %%f successfully.
        ) else (
            echo Error deleting %%f.
        )
    ) else (
        echo %%f does not exist. Skipping.
    )
)



@REM 启动复制管理器 
start "tao_ft_replicationmanager" cmd /k "%TAO_ROOT%/orbsvcs/FT_ReplicationManager/tao_ft_replicationmanager -o %PROJECT_PATH%/rm.ior -ORBEndpoint iiop://OMEN_2023:16423"
timeout /t 4


@REM echo "==>Start ft_replica1"
@REM start "ft_replica1" cmd /k "ft_replica -o %PROJECT_PATH%/factory1.ior -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:16423/ReplicationManager -l shire -i hobbit -q -p %PROJECT_PATH%/persistent.dat"
@REM timeout /t 4

@REM echo "==>Start ft_replica2"
@REM start "ft_replica2" cmd /k "ft_replica -o %PROJECT_PATH%/factory2.ior -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:16423/ReplicationManager -l bree -i hobbit -i elf -i human -q -u -p %PROJECT_PATH%/persistent.dat" 
@REM timeout /t 4

@REM echo "==>Start ft_replica3"
@REM start "ft_replica2" cmd /k "ft_replica -o %PROJECT_PATH%/factory3.ior -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:16423/ReplicationManager -l rivendell -i elf -q -u -p %PROJECT_PATH%/persistent.dat" 
@REM timeout /t 4

@REM echo "==>Start ft_create"
@REM start "ft_create" cmd /k "ft_create -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:16423/ReplicationManager -n -r hobbit -r elf -r hobbit -u human -i" 
@REM timeout /t 10

@REM echo "==>Start ft_client"
@REM start "ft_client" cmd /k "ft_client -f file://%PROJECT_PATH%/hobbit_shire_0.ior -f file://%PROJECT_PATH%/hobbit_bree_0.ior -c testscript"

@REM timeout /t 20
@REM echo "==>Start ft_client"
@REM start "ft_client" cmd /k "ft_client -f file://%PROJECT_PATH%/elf_bree_1.ior -f file://%PROJECT_PATH%/elf_rivendell_0.ior  -c testscript"
@REM timeout /t 20

@REM echo "==>Start ft_client"
@REM start "ft_client" cmd /k "ft_client -f file://%PROJECT_PATH%/hobbit_shire_1.ior -f file://%PROJECT_PATH%/hobbit_bree_2.ior -c testscript"
@REM timeout /t 20

@REM echo "==>Start replmgr_controller"
@REM start "replmgr_controller" cmd /k "replmgr_controller -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:16423/ReplicationManager -x"

@echo offs


@REM ========
@REM start %TAO_ROOT%/orbsvcs/FT_ReplicationManager/tao_ft_replicationmanager -o %PROJECT_PATH%/rm.ior -ORBEndpoint iiop://OMEN_2023:16423
@REM start ./ft_replica -o %PROJECT_PATH%/factory1.ior -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:16423/ReplicationManager -l shire -i hobbit -q -p %PROJECT_PATH%/persistent.dat
@REM start ./ft_replica -o %PROJECT_PATH%/factory2.ior -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:16423/ReplicationManager -l bree -i hobbit -i elf -i human -q -u -p %PROJECT_PATH%/persistent.dat
@REM start ./ft_replica -o %PROJECT_PATH%/factory3.ior -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:16423/ReplicationManager -l rivendell -i elf -q -u -p %PROJECT_PATH%/persistent.dat
@REM start ./ft_create -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:16423/ReplicationManager -n -r hobbit -r elf -r hobbit -u human -i
@REM start ./ft_client -f file://%PROJECT_PATH%/hobbit_shire_0.ior -f file://%PROJECT_PATH%/hobbit_bree_0.ior -c testscript
@REM start ./ft_client -f file://%PROJECT_PATH%/elf_bree_1.ior -f file://%PROJECT_PATH%/elf_rivendell_0.ior  -c testscript
@REM start ./ft_client -f file://%PROJECT_PATH%/hobbit_shire_1.ior -f file://%PROJECT_PATH%/hobbit_bree_2.ior -c testscript
@REM start ./replmgr_controller -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:16423/ReplicationManager -x


@REM 原始指令
@REM start E:\_proj\_opendds\ACE_wrappers\TAO/orbsvcs/FT_ReplicationManager/tao_ft_replicationmanager -o E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\rm.ior -ORBEndpoint iiop://OMEN_2023:16423
@REM start ./ft_replica -o E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\factory1.ior -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:16423/ReplicationManager -l shire -i hobbit -q -p E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\persistent.dat
@REM start ./ft_replica -o E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\factory2.ior -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:16423/ReplicationManager -l bree -i hobbit -i elf -i human -q -u -p E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\persistent.dat
@REM start ./ft_replica -o E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\factory3.ior -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:16423/ReplicationManager -l rivendell -i elf -q -u -p E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\persistent.dat
@REM start ./ft_create -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:16423/ReplicationManager -n -r hobbit -r elf -r hobbit -u human -i
@REM start ./ft_client -f file://E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\hobbit_shire_0.ior -f file://E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\hobbit_bree_0.ior -c testscript
@REM start ./ft_client -f file://E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\elf_bree_1.ior -f file://E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\elf_rivendell_0.ior  -c testscript
@REM start ./ft_client -f file://E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\hobbit_shire_1.ior -f file://E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\hobbit_bree_2.ior -c testscript
@REM start ./replmgr_controller -ORBInitRef ReplicationManager=corbaloc::OMEN_2023:16423/ReplicationManager -x
